home *** CD-ROM | disk | FTP | other *** search
/ 17 Bit Software 6: Level 6 / 17 Bit - Level 6 (1998)(Epic Marketing)[!].iso / quartz / q1082.dms / q1082.adf / src.lzh / Fig / movept.c < prev    next >
C/C++ Source or Header  |  1991-07-18  |  17KB  |  674 lines

  1. /* 
  2.  *    FIG : Facility for Interactive Generation of figures
  3.  *
  4.  *    Copyright (c) 1985 by Supoj Sutanthavibul (supoj@sally.UTEXAS.EDU)
  5.  *    January 1985.
  6.  *    1st revision : Aug 1985.
  7.  *
  8.  *    %W%    %G%
  9. */
  10. #include "fig.h"
  11. #include "resources.h"
  12. #include "func.h"
  13. #include "object.h"
  14. #include "paintop.h"
  15.  
  16. #define            TOLERANCE    3
  17. extern int        latexline_mode, latexarrow_mode;
  18. extern int        magnet_mode;
  19.  
  20. extern            (*canvas_kbd_proc)();
  21. extern            (*canvas_locmove_proc)();
  22. extern            (*canvas_leftbut_proc)();
  23. extern            (*canvas_middlebut_proc)();
  24. extern            (*canvas_rightbut_proc)();
  25. extern            null_proc();
  26. extern            set_popupmenu();
  27. F_line            *line_point_search();
  28. F_spline        *spline_point_search();
  29. F_ellipse        *ellipse_point_search();
  30. F_arc            *arc_point_search();
  31.  
  32. extern F_compound    objects;
  33.  
  34. extern F_point        *moved_point, *left_point;
  35. extern F_pos        last_position, new_position;
  36. extern int        movedpoint_num;
  37. extern int        last_object;
  38. extern int        fix_x, fix_y, cur_x, cur_y;
  39. extern int        pointmarker_shown;
  40. extern int        foreground_color, background_color;
  41.  
  42. extern            elastic_box(), move_ebrbox(), move_ebdbox();
  43. extern            move_cbrbox(), move_cbdbox();
  44.  
  45.             init_move_point();
  46.             move_linepoint(), fix_movedlinepoint();
  47.             move_latexlinepoint(), fix_movedlatexlinepoint();
  48.             fix_box();
  49.             fix_movedsplinepoint();
  50.             move_arcpoint(), fix_movedarcpoint();
  51.             fix_movedellipsepoint();
  52.  
  53. static F_line        *line;
  54. static F_spline        *spline;
  55. static F_ellipse    *ellipse;
  56. static F_arc        *arc;
  57.  
  58. static int        latex_fix_x, latex_fix_y;
  59. CURSOR            cur_latexcursor;
  60.  
  61. move_point_selected()
  62. {
  63.     canvas_kbd_proc = null_proc;
  64.     canvas_locmove_proc = null_proc;
  65.     canvas_leftbut_proc = init_move_point;
  66.     canvas_middlebut_proc = null_proc;
  67.     canvas_rightbut_proc = set_popupmenu;
  68.     set_cursor(&pick9_cursor);
  69.     reset_action_on();
  70.     }
  71.  
  72. init_move_point(x, y)
  73. int    x, y;
  74. {
  75.     if ((line = line_point_search(x, y, TOLERANCE,
  76.         &left_point, &moved_point)) != NULL) {
  77.         init_linepointmoving(line);
  78.         }
  79.     else if ((spline = spline_point_search(x, y, 
  80.         TOLERANCE, &left_point, &moved_point)) != NULL){
  81.         init_splinepointmoving(spline);
  82.         }
  83.     else if ((ellipse = ellipse_point_search(x, y, TOLERANCE, 
  84.         &movedpoint_num)) != NULL) {
  85.         init_ellipsepointmoving(ellipse);
  86.         }
  87.     else if ((arc = arc_point_search(x, y, TOLERANCE, 
  88.         &movedpoint_num)) != NULL) {
  89.         init_arcpointmoving(arc);
  90.         }
  91.     else {
  92.         return;
  93.         }
  94.     canvas_leftbut_proc = canvas_rightbut_proc = null_proc;
  95.     erase_pointmarker();
  96.     }
  97.  
  98. wrapup_movepoint()
  99. {
  100.     show_pointmarker();
  101.     move_point_selected();
  102.     }
  103.  
  104. /*************************  ellipse  *******************************/
  105.  
  106. F_ellipse *
  107. ellipse_point_search(x, y, tol, point_num)
  108. int    x, y, tol, *point_num;
  109. {
  110.     F_ellipse    *e;
  111.  
  112.     for (e = objects.ellipses; e != NULL; e = e->next) {
  113.         if (abs(e->start.x - x) <= tol && abs(e->start.y - y) <= tol) {
  114.         *point_num = 0;
  115.         return(e);
  116.         }
  117.         if (abs(e->end.x - x) <= tol && abs(e->end.y - y) <= tol) {
  118.         *point_num = 1;
  119.         return(e);
  120.         }
  121.         }
  122.     return(NULL);
  123.     }
  124.  
  125. static F_ellipse    *cur_e;
  126.  
  127. init_ellipsepointmoving(ellipse)
  128. F_ellipse    *ellipse;
  129. {
  130.     if (movedpoint_num == 0) {  /*  starting point is selected  */
  131.         if (ellipse->type == T_ELLIPSE_BY_RAD || 
  132.         ellipse->type == T_CIRCLE_BY_RAD) {
  133.         return;
  134.         }
  135.         last_position.x = cur_x = ellipse->start.x;
  136.         last_position.y = cur_y = ellipse->start.y;
  137.         fix_x = ellipse->end.x;  fix_y = ellipse->end.y;
  138.         switch (ellipse->type) {
  139.         case T_ELLIPSE_BY_DIA :
  140.             canvas_locmove_proc = move_ebdbox;
  141.             ellipsebydia_box(INV_PAINT);
  142.             break;
  143.         case T_CIRCLE_BY_DIA :
  144.             canvas_locmove_proc = move_cbdbox;
  145.             circlebydia_box(INV_PAINT);
  146.             break;
  147.         }
  148.         }
  149.     else {
  150.         last_position.x = cur_x = ellipse->end.x;
  151.         last_position.y = cur_y = ellipse->end.y;
  152.         fix_x = ellipse->start.x;  fix_y = ellipse->start.y;
  153.         switch (ellipse->type) {
  154.         case T_ELLIPSE_BY_RAD :
  155.             canvas_locmove_proc = move_ebrbox;
  156.             ellipsebyrad_box(INV_PAINT);
  157.             break;
  158.         case T_CIRCLE_BY_RAD :
  159.             canvas_locmove_proc = move_cbrbox;
  160.             circlebyrad_box(INV_PAINT);
  161.             break;
  162.         case T_ELLIPSE_BY_DIA :
  163.             canvas_locmove_proc = move_ebdbox;
  164.             ellipsebydia_box(INV_PAINT);
  165.             break;
  166.         case T_CIRCLE_BY_DIA :
  167.             canvas_locmove_proc = move_cbdbox;
  168.             circlebydia_box(INV_PAINT);
  169.             break;
  170.         }
  171.         }
  172.     cur_e = ellipse;
  173.     set_temp_cursor(&crosshair_cursor);
  174.     win_setmouseposition(canvas_swfd, cur_x, cur_y);
  175.     canvas_middlebut_proc = fix_movedellipsepoint;
  176.     canvas_leftbut_proc = null_proc;
  177.     }
  178.  
  179. fix_movedellipsepoint(x, y)
  180. int    x, y;
  181. {
  182.     switch (cur_e->type) {
  183.         case T_ELLIPSE_BY_RAD :
  184.         ellipsebyrad_box(INV_PAINT);
  185.         break;
  186.         case T_CIRCLE_BY_RAD :
  187.         circlebyrad_box(INV_PAINT);
  188.         break;
  189.         case T_ELLIPSE_BY_DIA :
  190.         ellipsebydia_box(INV_PAINT);
  191.         break;
  192.         case T_CIRCLE_BY_DIA :
  193.         circlebydia_box(INV_PAINT);
  194.         break;
  195.         }
  196.     new_position.x = x;
  197.     new_position.y = y;
  198.     clean_up();
  199.     set_action_object(F_MOVE_POINT, O_ELLIPSE);
  200.     set_latestellipse(cur_e);
  201.     relocate_ellipsepoint(cur_e, x, y, movedpoint_num);
  202.     wrapup_movepoint();
  203.     }
  204.  
  205. relocate_ellipsepoint(ellipse, x, y, point_num)
  206. F_ellipse    *ellipse;
  207. int        x, y, point_num;
  208. {
  209.     int    dx, dy;
  210.  
  211.     set_temp_cursor(&wait_cursor);
  212.     pw_batch_on(canvas_pixwin);
  213.     if (pointmarker_shown) toggle_ellipsepointmarker(ellipse);
  214.     draw_ellipse(ellipse, background_color);
  215.     if (point_num == 0) {  /*  starting point is selected  */
  216.         fix_x = ellipse->end.x;  fix_y = ellipse->end.y;
  217.         ellipse->start.x = x;  ellipse->start.y = y;
  218.         }
  219.     else {
  220.         fix_x = ellipse->start.x;  fix_y = ellipse->start.y;
  221.         ellipse->end.x = x;  ellipse->end.y = y;
  222.         }
  223.     switch (ellipse->type) {
  224.         case T_ELLIPSE_BY_RAD :
  225.         ellipse->radiuses.x = abs(x - fix_x) + 1;
  226.         ellipse->radiuses.y = abs(y - fix_y) + 1;
  227.         break;
  228.         case T_CIRCLE_BY_RAD :
  229.         dx = fix_x - x;  dy = fix_y - y;
  230.         ellipse->radiuses.x = sqrt((double)(dx*dx + dy*dy)) + .5;
  231.         ellipse->radiuses.y = ellipse->radiuses.x;
  232.         break;
  233.         case T_ELLIPSE_BY_DIA :
  234.         ellipse->center.x = (fix_x + x) / 2;
  235.         ellipse->center.y = (fix_y + y) / 2;
  236.         ellipse->radiuses.x = abs(ellipse->center.x - fix_x);
  237.         ellipse->radiuses.y = abs(ellipse->center.y - fix_y);
  238.         break;
  239.         case T_CIRCLE_BY_DIA :
  240.         dx = ellipse->center.x = (fix_x + x) / 2 +.5;
  241.         dy = ellipse->center.y = (fix_y + y) / 2 +.5;
  242.         dx -= x;  dy -= y; 
  243.         ellipse->radiuses.x = sqrt((double)(dx*dx + dy*dy)) + .5;
  244.         ellipse->radiuses.y = ellipse->radiuses.x;
  245.         break;
  246.         }
  247.     draw_ellipse(ellipse, foreground_color);
  248.     if (pointmarker_shown) toggle_ellipsepointmarker(ellipse);
  249.     pw_batch_off(canvas_pixwin);
  250.     reset_cursor();
  251.     set_modifiedflag();
  252.     }
  253.  
  254. /***************************  arc  *********************************/
  255.  
  256. static F_arc        *cur_a;
  257.  
  258. F_arc *
  259. arc_point_search(x, y, tol, point_num)
  260. int    x, y, tol, *point_num;
  261. {
  262.     F_arc    *a;
  263.     int    i;
  264.  
  265.     for(a = objects.arcs; a != NULL; a = a->next) {
  266.         for (i = 0; i < 3; i++) {
  267.         if (abs(a->point[i].x - x) <= tol && 
  268.             abs(a->point[i].y - y) <= tol) {
  269.             *point_num = i;
  270.             return(a);
  271.             }
  272.         }
  273.         }
  274.     return(NULL);
  275.     }
  276.  
  277. init_arcpointmoving(arc)
  278. F_arc    *arc;
  279. {
  280.     cur_a = arc;
  281.     last_position.x = cur_x = arc->point[movedpoint_num].x;
  282.     last_position.y = cur_y = arc->point[movedpoint_num].y;
  283.     set_temp_cursor(&crosshair_cursor);
  284.     win_setmouseposition(canvas_swfd, cur_x, cur_y);
  285.     draw_arclink(INV_PAINT);
  286.     canvas_locmove_proc = move_arcpoint;
  287.     canvas_middlebut_proc = fix_movedarcpoint;
  288.     canvas_leftbut_proc = null_proc;
  289.     }
  290.  
  291. move_arcpoint(x, y)
  292. int    x, y;
  293. {
  294.     draw_arclink(INV_PAINT);
  295.     cur_x = x;  cur_y = y;
  296.     draw_arclink(INV_PAINT);
  297.     }
  298.  
  299. draw_arclink(op)
  300. int    op;
  301. {
  302.     switch (movedpoint_num) {
  303.         case 0 :
  304.         pw_vector(canvas_pixwin, cur_x, cur_y,
  305.             arc->point[1].x, arc->point[1].y, op, 1);
  306.         break;
  307.         case 1 :
  308.         pw_vector(canvas_pixwin, arc->point[0].x, arc->point[0].y,
  309.             cur_x, cur_y, op, 1);
  310.         pw_vector(canvas_pixwin, arc->point[2].x, arc->point[2].y,
  311.             cur_x, cur_y, op, 1);
  312.         break;
  313.         default :
  314.         pw_vector(canvas_pixwin, arc->point[2].x, arc->point[2].y,
  315.             cur_x, cur_y, op, 1);
  316.         }
  317.     }
  318.  
  319. fix_movedarcpoint(x, y)
  320. int    x, y;
  321. {
  322.     draw_arclink(INV_PAINT);
  323.     new_position.x = x;
  324.     new_position.y = y;
  325.     clean_up();
  326.     set_action_object(F_MOVE_POINT, O_ARC);
  327.     set_latestarc(cur_a);
  328.     relocate_arcpoint(cur_a, x, y, movedpoint_num);
  329.     wrapup_movepoint();
  330.     }
  331.  
  332. relocate_arcpoint(arc, x, y, movedpoint_num)
  333. F_arc    *arc;
  334. int             x, y, movedpoint_num;
  335. {
  336.     float    xx, yy;
  337.     F_pos    p[3];
  338.  
  339.     p[0] = arc->point[0];
  340.     p[1] = arc->point[1];
  341.     p[2] = arc->point[2];
  342.     p[movedpoint_num].x = x;
  343.     p[movedpoint_num].y = y;
  344.     if (compute_arccenter(p[0], p[1], p[2], &xx, &yy)) {
  345.         set_temp_cursor(&wait_cursor);
  346.         pw_batch_on(canvas_pixwin);
  347.         if (pointmarker_shown) toggle_arcpointmarker(arc);
  348.         draw_arc(arc, background_color);    /* erase old arc */
  349.         arc->point[movedpoint_num].x = x;
  350.         arc->point[movedpoint_num].y = y;
  351.         arc->center.x = xx;
  352.         arc->center.y = yy;
  353.         arc->direction = compute_direction(p[0], p[1], p[2]);
  354.         draw_arc(arc, foreground_color);    /* draw new arc */
  355.         if (pointmarker_shown) toggle_arcpointmarker(arc);
  356.         pw_batch_off(canvas_pixwin);
  357.         reset_cursor();
  358.         set_modifiedflag();
  359.         }
  360.     }
  361.  
  362. /**************************  spline  *******************************/
  363.  
  364. static F_spline        *cur_s;
  365.  
  366. init_splinepointmoving(s)
  367. F_spline    *s;
  368. {
  369.     F_point    *p;
  370.  
  371.     cur_s = s;
  372.     last_position.x = cur_x = moved_point->x;
  373.     last_position.y = cur_y = moved_point->y;
  374.     set_temp_cursor(&crosshair_cursor);
  375.     win_setmouseposition(canvas_swfd, cur_x, cur_y);
  376.     if (closed_spline(s) && left_point == NULL) {
  377.         for (left_point = moved_point->next, 
  378.         p = left_point->next; 
  379.         p->next != NULL; 
  380.         left_point = p, p = p->next);
  381.         }
  382.     draw_pointlink(INV_PAINT);
  383.     canvas_locmove_proc = move_linepoint;
  384.     canvas_middlebut_proc = fix_movedsplinepoint;
  385.     canvas_leftbut_proc = null_proc;
  386.     }
  387.  
  388. F_spline *
  389. spline_point_search(x, y, tol, p, q)
  390. int    x, y, tol;
  391. F_point    **p, **q;
  392. {
  393.     F_spline    *s;
  394.  
  395.     for (s = objects.splines; s != NULL; s= s->next) {
  396.         *p = NULL;
  397.         for (*q = s->points; *q != NULL; *p = *q, *q = (*q)->next) {
  398.         if (abs((*q)->x - x) <= tol && abs((*q)->y - y) <= tol)
  399.             return(s);
  400.         }
  401.         }
  402.     return(NULL);
  403.     }
  404.  
  405. fix_movedsplinepoint(x, y)
  406. int    x, y;
  407. {
  408.     draw_pointlink(INV_PAINT);
  409.     new_position.x = x;
  410.     new_position.y = y;
  411.     clean_up();
  412.     set_action_object(F_MOVE_POINT, O_SPLINE);
  413.     set_latestspline(cur_s);
  414.     relocate_splinepoint(cur_s, x, y, moved_point);
  415.     wrapup_movepoint();
  416.     }
  417.  
  418. relocate_splinepoint(s, x, y, moved_point)
  419. F_spline    *s;
  420. int        x, y;
  421. F_point        *moved_point;
  422. {
  423.     set_temp_cursor(&wait_cursor);
  424.     pw_batch_on(canvas_pixwin);
  425.     if (pointmarker_shown) toggle_splinepointmarker(s);  
  426.     draw_spline(s, ERASE); /* erase old spline */
  427.     moved_point->x = x;
  428.     moved_point->y = y;
  429.     if (closed_spline(s)) {
  430.         left_point->next->x = x;
  431.         left_point->next->y = y;
  432.         }
  433.     if (int_spline(s)) remake_control_points(s);
  434.     draw_spline(s, PAINT); /* draw spline with moved point */
  435.     if (pointmarker_shown) toggle_splinepointmarker(s);  
  436.     pw_batch_off(canvas_pixwin);
  437.     reset_cursor();
  438.     set_modifiedflag();
  439.     }
  440.  
  441. /***************************  line  ********************************/
  442.  
  443. static F_line        *cur_l;
  444.  
  445. init_linepointmoving(line)
  446. F_line    *line;
  447. {
  448.     int    box_case;
  449.     int    latex_case;
  450.     F_point    *p;
  451.  
  452.     cur_l = line;
  453.     box_case = 0;
  454.     latex_case = 0;
  455.     last_position.x = cur_x = moved_point->x;
  456.     last_position.y = cur_y = moved_point->y;
  457.     set_temp_cursor(&crosshair_cursor);
  458.     win_setmouseposition(canvas_swfd, cur_x, cur_y);
  459.     switch (line->type) {
  460.         case T_POLYGON :
  461.         if (left_point == NULL)
  462.             for (left_point = moved_point->next, 
  463.             p = left_point->next; 
  464.             p->next != NULL; 
  465.             left_point = p, p = p->next);
  466.         break;
  467.         case T_BOX :
  468.         if (moved_point->next->next == NULL) { /* point 4 */
  469.             fix_x = line->points->next->x;
  470.             fix_y = line->points->next->y;
  471.             }
  472.         else {
  473.             fix_x = moved_point->next->next->x;
  474.             fix_y = moved_point->next->next->y;
  475.             }
  476.         draw_line(line, ERASE);
  477.         box_case = 1;
  478.         break;
  479.         case T_POLYLINE :
  480.         if (left_point != NULL) {
  481.             if (left_point == line->points) {
  482.             if (line->back_arrow) /*  backward arrow  */
  483.                 draw_arrow(cur_x, cur_y,
  484.                 left_point->x, left_point->y,
  485.                 line->back_arrow, ERASE);
  486.             }
  487.             }
  488.         else if (line->back_arrow) /*  backward arrow  */
  489.             draw_arrow(moved_point->next->x, moved_point->next->y,
  490.             cur_x, cur_y, line->back_arrow, ERASE);
  491.         p = moved_point->next;
  492.         if (p != NULL) {
  493.             if (line->for_arrow && p->next == NULL) 
  494.             draw_arrow(cur_x, cur_y, p->x, p->y, 
  495.                 line->for_arrow, ERASE);
  496.             }
  497.         else if (line->for_arrow)/* f arrow */
  498.             draw_arrow(left_point->x, left_point->y, 
  499.             cur_x, cur_y, line->for_arrow, ERASE);
  500.         if (latexline_mode || latexarrow_mode) {
  501.             if (left_point != NULL) {
  502.             latex_fix_x = left_point->x;
  503.             latex_fix_y = left_point->y;
  504.             latex_case = 1;
  505.             }
  506.             else if (p != NULL) {
  507.             latex_fix_x = p->x;
  508.             latex_fix_y = p->y;
  509.             latex_case = 1;
  510.             }
  511.             }
  512.         }
  513.     if (box_case) {
  514.         draw_rectbox(fix_x, fix_y, cur_x, cur_y, INV_PAINT);
  515.         canvas_locmove_proc = elastic_box;
  516.         canvas_middlebut_proc = fix_box;
  517.         }
  518.     else if (latex_case) {
  519.         draw_pointlink(INV_PAINT);
  520.         canvas_locmove_proc = move_latexlinepoint;
  521.         canvas_middlebut_proc = fix_movedlatexlinepoint;
  522.         cur_latexcursor = &crosshair_cursor;
  523.         }
  524.     else {
  525.         draw_pointlink(INV_PAINT);
  526.         canvas_locmove_proc = move_linepoint;
  527.         canvas_middlebut_proc = fix_movedlinepoint;
  528.         }
  529.     canvas_leftbut_proc = null_proc;
  530.     }
  531.  
  532. move_linepoint(x, y)
  533. int    x, y;
  534. {
  535.     draw_pointlink(INV_PAINT);
  536.     cur_x = x;
  537.     cur_y = y;
  538.     draw_pointlink(INV_PAINT);
  539.     }
  540.  
  541. move_latexlinepoint(x, y)
  542. int    x, y;
  543. {
  544.     CURSOR     c;
  545.  
  546.     draw_pointlink(INV_PAINT);
  547.     latex_endpoint(latex_fix_x, latex_fix_y, x, y, &cur_x, &cur_y,
  548.         latexarrow_mode, (magnet_mode)? 5: 1);
  549.     draw_pointlink(INV_PAINT);
  550.     c = (x == cur_x  &&  y == cur_y)? &null_cursor: &crosshair_cursor;
  551.     if (c != cur_latexcursor) {
  552.         set_temp_cursor(c);
  553.         cur_latexcursor = c;
  554.         }
  555.     }
  556.  
  557. fix_box(x, y)
  558. int    x, y;
  559. {
  560.     draw_rectbox(fix_x, fix_y, cur_x, cur_y, INV_PAINT);
  561.     new_position.x = x;
  562.     new_position.y = y;
  563.     clean_up();
  564.     set_action_object(F_MOVE_POINT, O_POLYLINE);
  565.     set_latestline(line);
  566.     relocate_linepoint(line, x, y, fix_x, fix_y, moved_point, 
  567.         left_point);
  568.     wrapup_movepoint();
  569.     }
  570.  
  571. assign_newboxpoint(b, x1, y1, x2, y2)
  572. F_line    *b;
  573. int    x1, y1, x2, y2;
  574. {
  575.     F_point    *p;
  576.  
  577.     p = b->points;
  578.     p->x = x1;    p->y = y1;    p = p->next;
  579.     p->x = x1;    p->y = y2;    p = p->next;
  580.     p->x = x2;    p->y = y2;    p = p->next;
  581.     p->x = x2;    p->y = y1;    p = p->next;
  582.     p->x = x1;    p->y = y1;    p = p->next;
  583.     }
  584.  
  585. fix_movedlinepoint(x, y)
  586. int    x, y;
  587. {
  588.     draw_pointlink(INV_PAINT);
  589.     new_position.x = x;
  590.     new_position.y = y;
  591.     clean_up();
  592.     set_action_object(F_MOVE_POINT, O_POLYLINE);
  593.     set_latestline(cur_l);
  594.     relocate_linepoint(cur_l, x, y, fix_x, fix_y, moved_point, left_point);
  595.     wrapup_movepoint();
  596.     }
  597.  
  598. fix_movedlatexlinepoint(x, y)
  599. int    x, y;
  600. {
  601.     draw_pointlink(INV_PAINT);
  602.     latex_endpoint(latex_fix_x, latex_fix_y, x, y, &x, &y,
  603.         latexarrow_mode, (magnet_mode)? 5: 1);
  604.     if (cur_latexcursor != &crosshair_cursor)
  605.         set_temp_cursor(&crosshair_cursor);
  606.     win_setmouseposition(canvas_swfd, x, y);
  607.     new_position.x = x;
  608.     new_position.y = y;
  609.     clean_up();
  610.     set_action_object(F_MOVE_POINT, O_POLYLINE);
  611.     set_latestline(cur_l);
  612.     relocate_linepoint(cur_l, x, y, fix_x, fix_y, moved_point, left_point);
  613.     wrapup_movepoint();
  614.     }
  615.  
  616. relocate_linepoint(line, x, y, fix_x, fix_y, moved_point, left_point)
  617. F_line    *line;
  618. int    x, y;
  619. F_point    *moved_point, *left_point;
  620. {
  621.     if (pointmarker_shown) toggle_linepointmarker(line);
  622.     draw_line(line, ERASE);
  623.     switch (line->type) {
  624.         case T_BOX :
  625.         assign_newboxpoint(line, fix_x, fix_y, x, y);
  626.         break;
  627.         case T_POLYGON :
  628.         if (line->points == moved_point) {
  629.             left_point->next->x = x;
  630.             left_point->next->y = y;
  631.             }
  632.         default :
  633.         moved_point->x = x;
  634.         moved_point->y = y;
  635.         }
  636.     draw_line(line, PAINT);
  637.     if (pointmarker_shown) toggle_linepointmarker(line);  
  638.     set_modifiedflag();
  639.     }
  640.  
  641. draw_pointlink(op)
  642. int    op;
  643. {
  644.     F_point    *p;
  645.  
  646.     if (left_point != NULL) {
  647.         pw_vector(canvas_pixwin, left_point->x, left_point->y,
  648.             cur_x, cur_y, op, 1);
  649.         }
  650.     if ((p = moved_point->next) != NULL) {
  651.         pw_vector(canvas_pixwin, p->x, p->y, cur_x, cur_y, op, 1);
  652.         }
  653.     }
  654.  
  655. F_line *
  656. line_point_search(x, y, tol, p, q)
  657. int    x, y, tol;
  658. F_point    **p, **q;
  659. {
  660.     F_line    *l;
  661.     F_point    *a, *b;
  662.  
  663.     for (l = objects.lines; l != NULL; l= l->next) {
  664.         for (a = NULL, b = l->points; b != NULL; a = b, b = b->next) {
  665.         if (abs(b->x - x) <= tol && abs(b->y - y) <= tol) {
  666.             *p = a;
  667.             *q = b;
  668.             return(l);
  669.             }
  670.         }
  671.         }
  672.     return(NULL);
  673.     }
  674.